using ASP;
using HoWave.Common;
using HoWave.Web.Admin;
using HoWave.Web.DataHelper;
using System;
using System.Drawing;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_Witkey : Admin, IRequiresSessionState
{
	protected DropDownList DropDownList_WitkeyTypeOne;
	protected DropDownList DropDownList_Statu;
	protected DropDownList DropDownList_Mode;
	protected HtmlInputText input_Id;
	protected Button Button_Search;
	protected LinkButton LinkButton0;
	protected LinkButton LinkButton1;
	protected LinkButton LinkButton2;
	protected LinkButton LinkButton3;
	protected LinkButton LinkButton4;
	protected LinkButton LinkButton5;
	protected LinkButton LinkButton6;
	protected LinkButton LinkButton7;
	protected LinkButton LinkButton8;
	protected LinkButton LinkButton9;
	protected HtmlInputHidden hidden_checkbox;
	protected ImageButton ImageButton_IDUp;
	protected ImageButton ImageButton_IDDown;
	protected ImageButton ImageButton_TimeUp;
	protected ImageButton ImageButton_TimeDown;
	protected ImageButton ImageButton_EndTimeDown;
	protected Repeater Repeater_Witkey;
	protected Button Button_Check;
	protected Button Button_Delete;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.AdminGroup();
		if (!base.IsPostBack)
		{
			this.InitPage("", 0, "", "-1", 0, 0, 0);
		}
	}
	protected void AdminGroup()
	{
		if (!base.admin.CheckAdminPower(37))
		{
			base.WriteRightErrMsg();
		}
		if (!base.admin.CheckAdminPower(37))
		{
			this.Button_Delete.Visible = false;
		}
		if (!base.admin.CheckAdminPower(37))
		{
			this.Button_Check.Visible = false;
		}
	}
	protected void InitPage(string ww_Id, int ww_Type, string ww_WitkeyTypeOne, string ww_Statu, int ww_IdUp, int ww_StartTimeUp, int ww_EndTimeUp)
	{
		Shop_Witkey shop_Witkey = new Shop_Witkey();
		this.Repeater_Witkey.DataSource = shop_Witkey.GetWitkeyAllByWhere(ww_Id, ww_Type, ww_WitkeyTypeOne, ww_Statu, ww_IdUp, ww_StartTimeUp, ww_EndTimeUp);
		this.Repeater_Witkey.DataBind();
		this.ViewState["ww_Id"] = ww_Id;
		this.ViewState["ww_Type"] = ww_Type;
		this.ViewState["ww_WitkeyTypeOne"] = ww_WitkeyTypeOne;
		this.ViewState["ww_Statu"] = ww_Statu;
		this.ViewState["ww_IdUp"] = ww_IdUp;
		this.ViewState["ww_StartTimeUp"] = ww_StartTimeUp;
		this.ViewState["ww_EndTimeUp"] = ww_EndTimeUp;
	}
	protected void LinkButton_Command(object sender, CommandEventArgs e)
	{
		this.ViewState["ww_Statu"] = e.CommandName;
		this.LinkButton0.ForeColor = Color.Black;
		this.LinkButton1.ForeColor = Color.Black;
		this.LinkButton2.ForeColor = Color.Black;
		this.LinkButton3.ForeColor = Color.Black;
		this.LinkButton4.ForeColor = Color.Black;
		this.LinkButton5.ForeColor = Color.Black;
		this.LinkButton6.ForeColor = Color.Black;
		this.LinkButton7.ForeColor = Color.Black;
		this.LinkButton8.ForeColor = Color.Black;
		this.LinkButton9.ForeColor = Color.Black;
		this.Button_Check.Enabled = false;
		string commandName = e.CommandName;
		switch (commandName)
		{
		case "0":
			this.LinkButton0.ForeColor = Color.Red;
			break;
		case "1":
			this.LinkButton1.ForeColor = Color.Red;
			break;
		case "2":
			this.LinkButton2.ForeColor = Color.Red;
			this.Button_Check.Enabled = true;
			break;
		case "3":
			this.LinkButton3.ForeColor = Color.Red;
			break;
		case "4":
			this.LinkButton4.ForeColor = Color.Red;
			break;
		case "5":
			this.LinkButton5.ForeColor = Color.Red;
			break;
		case "6":
			this.LinkButton6.ForeColor = Color.Red;
			break;
		case "7":
			this.LinkButton7.ForeColor = Color.Red;
			break;
		case "8":
			this.LinkButton8.ForeColor = Color.Red;
			break;
		case "9":
			this.LinkButton9.ForeColor = Color.Red;
			break;
		}
		commandName = e.CommandName;
		if (commandName != null)
		{
			if (commandName == "0")
			{
				this.InitPage("", 0, "", "-1", 0, 0, 0);
				return;
			}
		}
		this.InitPage(this.ViewState["ww_Id"].ToString(), Convert.ToInt32(this.ViewState["ww_Type"]), this.ViewState["ww_WitkeyTypeOne"].ToString(), e.CommandName, Convert.ToInt32(this.ViewState["ww_IdUp"]), Convert.ToInt32(this.ViewState["ww_StartTimeUp"]), Convert.ToInt32(this.ViewState["ww_EndTimeUp"]));
	}
	protected void Button_Search_Click(object sender, EventArgs e)
	{
		string value = this.input_Id.Value;
		string text = "";
		if (this.DropDownList_WitkeyTypeOne.SelectedValue != "-1")
		{
			text = this.DropDownList_WitkeyTypeOne.SelectedItem.Text;
		}
		string selectedValue = this.DropDownList_Statu.SelectedValue;
		int num = Convert.ToInt32(this.DropDownList_Mode.SelectedValue);
		this.ViewState["ww_Id"] = value;
		this.ViewState["ww_WitkeyTypeOne"] = text;
		this.ViewState["ww_Statu"] = selectedValue;
		this.ViewState["ww_Type"] = num;
		this.InitPage(value, num, text, selectedValue, Convert.ToInt32(this.ViewState["ww_IdUp"]), Convert.ToInt32(this.ViewState["ww_StartTimeUp"]), Convert.ToInt32(this.ViewState["ww_EndTimeUp"]));
	}
	protected void ImageButton_IDUp_Click(object sender, ImageClickEventArgs e)
	{
		this.ViewState["ww_IdUp"] = 1;
		this.InitPage(this.ViewState["ww_Id"].ToString(), Convert.ToInt32(this.ViewState["ww_Type"]), this.ViewState["ww_WitkeyTypeOne"].ToString(), this.ViewState["ww_Statu"].ToString(), Convert.ToInt32(this.ViewState["ww_IdUp"]), 0, 0);
	}
	protected void ImageButton_IDDown_Click(object sender, ImageClickEventArgs e)
	{
		this.ViewState["ww_IdUp"] = 2;
		this.InitPage(this.ViewState["ww_Id"].ToString(), Convert.ToInt32(this.ViewState["ww_Type"]), this.ViewState["ww_WitkeyTypeOne"].ToString(), this.ViewState["ww_Statu"].ToString(), Convert.ToInt32(this.ViewState["ww_IdUp"]), 0, 0);
	}
	protected void ImageButton_TimeUp_Click(object sender, ImageClickEventArgs e)
	{
		this.ViewState["ww_StartTimeUp"] = 1;
		this.InitPage(this.ViewState["ww_Id"].ToString(), Convert.ToInt32(this.ViewState["ww_Type"]), this.ViewState["ww_WitkeyTypeOne"].ToString(), this.ViewState["ww_Statu"].ToString(), 0, Convert.ToInt32(this.ViewState["ww_StartTimeUp"]), 0);
	}
	protected void ImageButton_TimeDown_Click(object sender, ImageClickEventArgs e)
	{
		this.ViewState["ww_StartTimeUp"] = 2;
		this.InitPage(this.ViewState["ww_Id"].ToString(), Convert.ToInt32(this.ViewState["ww_Type"]), this.ViewState["ww_WitkeyTypeOne"].ToString(), this.ViewState["ww_Statu"].ToString(), 0, Convert.ToInt32(this.ViewState["ww_StartTimeUp"]), 0);
	}
	protected void ImageButton_EndTimeDown_Click(object sender, ImageClickEventArgs e)
	{
		this.ViewState["ww_EndTimeUp"] = 2;
		this.InitPage(this.ViewState["ww_Id"].ToString(), Convert.ToInt32(this.ViewState["ww_Type"]), this.ViewState["ww_WitkeyTypeOne"].ToString(), this.ViewState["ww_Statu"].ToString(), 0, 0, Convert.ToInt32(this.ViewState["ww_EndTimeUp"]));
	}
	protected void LinkButton_Edit_Command(object sender, CommandEventArgs e)
	{
		if (!base.admin.CheckAdminPower(37))
		{
			base.WriteRightErrMsg();
		}
		int num = int.Parse(e.CommandName);
		base.Server.Transfer("Admin_UpdateWitkey.aspx?ww_Id=" + num);
	}
	protected void LinkButton_Delete_Command(object sender, CommandEventArgs e)
	{
		if (!base.admin.CheckAdminPower(37))
		{
			base.WriteRightErrMsg();
		}
		int ww_Id = int.Parse(e.CommandName);
		Shop_Witkey shop_Witkey = new Shop_Witkey();
		shop_Witkey.DeleteWitkey(ww_Id);
		base.Response.Redirect("Admin_Witkey.aspx");
	}
	protected void Button_Check_Click(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(37))
		{
			base.WriteRightErrMsg();
		}
		if (base.Request["id"] != null && base.Request["id"] != string.Empty)
		{
			string str = base.Request["id"].ToString();
			string sql = "UPDATE [HLWitkey_Witkey] SET [ww_Statu] = 4 WHERE [ww_Id] IN(" + str + ")";
			bool flag = this.conn.Execute(sql) >= 1;
			if (flag)
			{
				this.WriteSuccessMsg("", Language.GetAdminMsg("Common/CheckSuccess"), "Admin_Witkey.aspx");
			}
		}
	}
	protected void Button_Delete_Click(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(37))
		{
			base.WriteRightErrMsg();
		}
		if (base.Request["id"] != null && base.Request["id"] != string.Empty)
		{
			string str = base.Request["id"].ToString();
			string sql = "DELETE FROM [HLWitkey_Witkey] WHERE [ww_Id] IN(" + str + ")";
			bool flag = this.conn.Execute(sql) >= 1;
			if (flag)
			{
				this.WriteSuccessMsg("", Language.GetAdminMsg("Common/DeleteSuccess"), "Admin_Witkey.aspx");
			}
		}
	}
}
